package com.yeyuanqi.dao;

import com.yeyuanqi.model.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface  UserMapper  {
//    //根据id查询用户信息
//    @Select("SELECT * FROM t_user WHERE id=#{id}")
//    public User selectUserWithId(Integer id);
//
//    //根据用户名查询用户信息
//    @Select("SELECT * FROM t_user WHERE username=#{username}")
//    public User selectUserWithName(String username);

    //用户分页查询
    @Select("SELECT * FROM t_user ORDER BY id DESC")
    public List<User> selectUserWithPage();

    //根据id删除用户
    @Delete("DELETE FROM t_user WHERE id=#{id}")
    public int deleteUserWithId(int id);

    //增加用户，根据@Options获取自动生成的id
    @Insert("INSERT INTO t_user(username，password，email)" +
            "values (#{username},#{password},#{email})")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    public Integer publishUser(User user);

//
//    //根据id更新用户
//    public Integer updateUserWithId(User user);
//

}